﻿/* Filename: DemonTemplate.as 
 *
 * Description: This class is the template
 * for particular Demons.  Demon.as extends
 * this class to make individual types of
 * demons.  This class extends ElementType
 * to give the demons an element type that
 * changes how terrain and attacks affect them.
 *
 * Tyler Samson
 * Feb 2008
 * @ Sierra Nevada College
 */
 class DemonTemplate extends ElementType {
	private var _demonName:String;					// name of this demon
	private var _healthFull:Number;					// full health of this demon
	private var _health:Number;						// health of this demon
	private var _attacks:Array;						// demons's attacks
	private var _terrainAttacks:Array;				// demons's terrain attacks
	
	private var _graphicName:String;				// name of the demon image stored in files
	private var _graphicFormat:String = ".swf"		// format of the stored graphic
	private var _graphicNameBig:String;				// name of the demon image stored in files
	private var _graphicFormatBig:String = ".swf"	// format of the stored graphic
	
	public function DemonTemplate(p_demonName:String, p_elementType:String, p_health:Number,
						  			p_attacks:Array, p_terrainAttacks:Array) {
		
		super(p_elementType);	// Set the element type of this demon
		_demonName = p_demonName;
		_healthFull = p_health;
		_health = p_health;
		_graphicName = "demons/demon" + _demonName + _graphicFormat;
		_graphicNameBig = "bigDemons/demon" + _demonName + _graphicFormatBig;
		
		_attacks = new Array(p_attacks.length);
		for (var i = 0; i < p_attacks.length; i++) {
			_attacks[i] = p_attacks[i];
		}
		
		_terrainAttacks = new Array(p_terrainAttacks.length);
		for (var i = 0; i < p_terrainAttacks.length; i++) {
			_terrainAttacks[i] = p_terrainAttacks[i];
		}
	}
	
	// Return the Demon's name
	public function getName():String {
		return _demonName;
	}
	
	// Return the Demon's full health
	public function getHealthFull():Number {
		return _healthFull;
	}
	
	// Return the Demon's health
	public function getHealth():Number {
		return _health;
	}
	
	// Return a list of the attacks this demon possesses.
	public function getAttacks():Array {
		return _attacks;
	}
	
	// Return a list of the terrain attacks this demon possesses.
	public function getTerrainAttacks():Array {
		return _terrainAttacks;
	}
	
	// Return the stored name of the map graphic for this demon
	public function graphicName():String {
		return _graphicName;
	}
	
	// Return the stored name of the side-bar graphic for this demon
	public function graphicNameBig():String {
		return _graphicNameBig;
	}
	
	// Change the Demon's health based on the parameter
	public function changeHealth(p_change:Number) {
		_health = _health + p_change;
	}
	
	public function isDead():Boolean {
		var _returnValue = false;
		
		if (_health <= 0 ){
			_returnValue = true;
		}
		
		return _returnValue;
	}
}
